/**
 * NF Preview Selector - Floating Window Styles
 */


.nf-float {
    position: absolute;
    z-index: 999999;
    border: 2px solid #333;
    background-color: rgba(45, 45, 45, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    max-width: 800px;
    min-height: 300px; /* Minimum height for proper layout */
    font-family: Arial, sans-serif;
    resize: both;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.nf-float.hidden {
    display: none;
}

.nf-float-header {
    width: 100%;
    text-align: center;
    background-color: rgba(70, 130, 180, 0.9);
    color: white;
    border-bottom: 1px solid #333;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: move;
    border-radius: 6px 6px 0 0;
    user-select: none;
    flex-shrink: 0; /* Don't shrink header */
}

.nf-float-header:hover {
    background-color: rgba(70, 130, 180, 1);
}

.nf-float-body {
    padding: 12px;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1; /* Take remaining space */
    min-height: 0; /* Allow shrinking */
}

/* Image Grid */
.nf-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--min-column-width, 150px), 1fr));
    gap: 8px;
    flex: 1; /* Take up remaining space */
    overflow-y: auto;
    min-height: 0; /* Allow shrinking */
    align-items: start;
}

/* Smart grid layout that adapts to content and window size */
.nf-image-grid.smart-grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--min-column-width, 150px), 1fr));
    gap: 8px;
    align-items: start;
}

/* ComfyUI-style layout with optimized calculations */
.nf-image-grid.comfyui-layout {
    display: grid;
    grid-template-columns: repeat(var(--max-columns, auto-fit), var(--min-column-width, 150px));
    grid-template-rows: repeat(var(--max-rows, auto-fit), var(--cell-height, auto));
    gap: 8px;
    align-items: center;
    justify-content: center;
    align-content: start;
}

.nf-image-container {
    position: relative;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ComfyUI-style image containers with fixed dimensions */
.nf-image-grid.comfyui-layout .nf-image-container {
    width: var(--min-column-width, 150px);
    height: var(--cell-height, 150px);
}

/* Responsive image containers */
.nf-image-grid.smart-grid-layout .nf-image-container {
    width: 100%;
    max-width: 100%;
}

.nf-image-container:hover {
    border-color: #70a0d0;
}

.nf-image-container.selected {
    border-color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.1);
}

.nf-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
}

/* ComfyUI-style images with fixed dimensions */
.nf-image-grid.comfyui-layout .nf-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nf-image-overlay {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.nf-image-container.selected .nf-image-overlay {
    background-color: rgba(76, 175, 80, 0.9);
}

/* Controls */
.nf-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #555;
    margin-top: auto; /* Push to bottom */
    flex-shrink: 0; /* Don't shrink */
}

.nf-selection-info {
    font-size: 12px;
    color: #ccc;
}

.nf-buttons {
    display: flex;
    gap: 8px;
}

.nf-button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.nf-button.primary {
    background-color: #4CAF50;
    color: white;
}

.nf-button.primary:hover {
    background-color: #45a049;
}

.nf-button.primary:disabled {
    background-color: #666;
    cursor: not-allowed;
}

.nf-button.secondary {
    background-color: #666;
    color: white;
}

.nf-button.secondary:hover {
    background-color: #777;
}

.nf-button.pin {
    background-color: #2196F3;
    color: white;
    padding: 8px 12px;
    min-width: 40px;
    font-size: 14px;
}

.nf-button.pin:hover {
    background-color: #1976D2;
}

.nf-button.pin.active {
    background-color: #FF9800;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

.nf-button.pin.active:hover {
    background-color: #F57C00;
}

/* Countdown */
.nf-countdown {
    font-size: 11px;
    color: #ff9800;
    text-align: center;
    padding: 4px;
}

/* Waiting Message */
.nf-waiting-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 16px;
    color: #888;
    text-align: center;
    font-style: italic;
    border: 2px dashed #666;
    border-radius: 8px;
    margin: 20px;
}

/* Max width is now configurable via settings */